﻿//-------------------------------------------------------------------
//版权所有：版权所有(C) 2010， YIBO(China) Studio 
//系统名称：验证控件
//文件名称：InputMoneyClientValidator.cs
//模块名称：验证控件
//模块编号：
//作　　者：LHC
//完成日期：2010/8/29 14:34:00
//功能说明：
//-----------------------------------------------------------------
//修改记录：
//修改人：  
//修改时间：
//修改内容：
//-------------------------------------------------------------------
using System.Globalization;

namespace MvcMall.Framework.FormValidator
{

    /// <summary>
    /// 价格验证
    /// </summary>
    public class InputMoneyClientValidator : ClientValidator
    {
        /// <summary>
        /// 创建控件容器
        /// </summary>
        /// <returns>返回容器对象</returns>
        internal override ValidateRenderControl GenerateAppendScript()
        {
            return new ValidateRenderControl();
        }

        /// <summary>
        /// 注册验证规则
        /// </summary>
        /// <returns>返回输出容器</returns>
        internal override ValidateRenderControl GenerateInitScript()
        {
            ValidateRenderControl control = new ValidateRenderControl();
            control.Text = string.Format(CultureInfo.InvariantCulture, "initValid(new InputValidator('{0}', 1, 10, {1}, '{2}', '{3}', '{4}'", new object[] { base.Owner.TargetClientId, base.Owner.Nullable ? "true" : "false", @"(0|-?[0-9]\\d*(\\.\\d{1,2})?)", base.Owner.Nullable ? base.Owner.FocusMessage : (base.Owner.RequiredAlt + base.Owner.FocusMessage), base.Owner.Nullable ? this.ErrorMessage : (base.Owner.RequiredMessage  + this.ErrorMessage) });
            if (base.Owner.Nullable)
            {
                control.Text = control.Text + string.Format(CultureInfo.InvariantCulture, ", '{0}'", new object[] { base.Owner.NullMessage });
            }
            control.Text = control.Text + "));";
            return control;
        }
    }
}

